package top.fangw.admin.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.fangw.admin.pojo.entity.SysApplication;
import top.fangw.admin.service.ISysMenuService;
import top.fangw.common.api.vo.InitTenantMenu;
import top.fangw.common.core.result.Result;

import java.util.List;

/**
 * <p>
 * 用途：存储菜单信息 前端控制器
 * </p>
 *
 * @author fangw
 * @since 2024-03-02
 */
@Tag(name = "菜单信息管理")
@RestController
@RequestMapping("/sys-menu")
@RequiredArgsConstructor
public class SysMenuController {

    private final ISysMenuService sysMenuService;


    @Operation(summary = "初始化租户菜单信息")
    @PostMapping("/initTenantMenu")
    public Result<?> initTenantMenu(@RequestBody InitTenantMenu initTenantMenu){
        sysMenuService.initTenantMenu(initTenantMenu);
        return Result.success();
    }

    @Operation(summary = "查询应用及应用下的菜单信息")
    @GetMapping("/getApplicationAndMenu")
    public Result<?> getApplicationAndMenu(){
        List<SysApplication> res = sysMenuService.getApplicationAndMenu();
        return Result.success(res);
    }
}
